<template>
  <div>
      <el-select v-model="yj" placeholder="请选择处理意见id">
        <el-option
          v-for="dict in dict.type.clyj"
          :key="dict.value"
          :label="dict.label"
          :value="parseInt(dict.value)"
        ></el-option>
      </el-select>
    <el-button type="primary" @click="queding">确 定</el-button>
    <el-button @click="fanhui">返回</el-button>
  </div>
</template>

<script>
  import {updateJubaoguanli } from "@/api/system/jubaoguanli";
  export default {
      name: "jubaochuli",
      dicts: ['clyj'],
      data(){
        return{
          value:'',
          yj:'',
        }
      },
      created() {
        this.getData();
      },
      methods:{
        getData(){
          this.value = JSON.parse(localStorage.getItem('jubaochuli'));
          console.log(this.value)
        },
        queding(){
          this.value.jbglClyj = this.yj;
          this.value.ztId = 2
          this.value.jbglClsj = this.getGoodTime(new Date())
          updateJubaoguanli(this.value).then(response => {
            this.$modal.msgSuccess("处理成功");
          });
          this.$router.go(-1);
        },
        fanhui(){
          this.$router.go(-1);
        },
        //时间格式转化
        getGoodTime(time) {
          // 尝试将输入字符串解析为Date对象
          let date = new Date(time);
          // 检查Date对象是否有效（即不是Invalid Date）
          if (isNaN(date.getTime())) {
            throw new Error('Invalid date string');
          }
          // 提取年、月、日、时、分、秒
          // 月份从0开始，所以要加1；日期、小时、分钟、秒直接使用
          // 使用padStart来确保月份、日期、小时、分钟、秒始终是两位数
          const year = time.getFullYear();
          const month = String(time.getMonth() + 1).padStart(2, '0');
          const day = String(time.getDate()).padStart(2, '0');
          const hours = String(time.getHours()).padStart(2, '0');
          const minutes = String(time.getMinutes()).padStart(2, '0');
          const seconds = String(time.getSeconds()).padStart(2, '0');

          // 拼接成所需的格式
          return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
        }
      }
    }
</script>

<style scoped>

</style>
